package week3;

import java.util.Scanner;
class Person1{
	private String name;
	private boolean gender;
	private int age;
	private static int id;
	public Person1(){
		System.out.println("This is constructor");
		System.out.println(this.name 

+","+this.age+","+this.gender+","+this.id 

);
	}
	public Person1(String name,int age,boolean gender){
		this.name = name;
		this.gender = gender;
		this.age = age;
	}

	public String toString() {
		String s = "Person [name=" + name + ", age=" + age + ", gender=" + this.gender + ", id=" + id + "]";
		this.id +=1;
		return s;
		
	}

	{
		System.out.println("This is initialization block, id is "+this.id );
		
	}

	static{
		System.out.println("This is static initialization block");
	}

}


public class Main2 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in );
		int n = sc.nextInt();
		sc.nextLine();
		String str[] = new String[n];
		for(int i=0;i<n;i++){
			//sc.nextLine();
			str[i] = sc.nextLine();
			
		}
		
		String[] p2 = new String[n];
		for(int i=0;i<n;i++){
			String[] ch = str[i].split(" ");
			int ages = Integer.parseInt(ch[1]);
			//boolean gen = Boolean.getBoolean(ch[2]);
			Person1 p1 = new Person1(ch[0],ages,Boolean.valueOf(ch[2]));
			p2[i] = p1.toString();
			
		}
		for(int i=n-1;i>=0;i--){
			System.out.println(p2[i]);
		}
        Person1 p = new Person1();
		
		System.out.println(p.toString());
		sc.close();

	}

}